package com.uidt.project.ptsj.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.uidt.framework.aspectj.lang.annotation.Log;
import com.uidt.framework.aspectj.lang.enums.BusinessType;
import com.uidt.project.ptsj.domain.ScoreRecord;
import com.uidt.project.ptsj.service.IScoreRecordService;
import com.uidt.framework.web.controller.BaseController;
import com.uidt.framework.web.domain.AjaxResult;
import com.uidt.common.utils.poi.ExcelUtil;
import com.uidt.framework.web.page.TableDataInfo;

/**
 * 打分记录Controller
 * 
 * @author uidt
 * @date 2024-08-12
 */
@RestController
@RequestMapping("/ptsj/score")
public class ScoreRecordController extends BaseController
{
    @Autowired
    private IScoreRecordService ptsjScoreRecordService;

    /**
     * 查询打分记录列表
     */
//    @PreAuthorize("@ss.hasPermi('ptsj:score:list')")
    @GetMapping("/list")
    public TableDataInfo list(ScoreRecord ptsjScoreRecord)
    {
        startPage();
        List<ScoreRecord> list = ptsjScoreRecordService.selectScoreRecordList(ptsjScoreRecord);
        return getDataTable(list);
    }

    /**
     * 导出打分记录列表
     */
    @PreAuthorize("@ss.hasPermi('ptsj:score:export')")
    @Log(title = "打分记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ScoreRecord ptsjScoreRecord)
    {
        List<ScoreRecord> list = ptsjScoreRecordService.selectScoreRecordList(ptsjScoreRecord);
        ExcelUtil<ScoreRecord> util = new ExcelUtil<ScoreRecord>(ScoreRecord.class);
        util.exportExcel(response, list, "打分记录数据");
    }

    /**
     * 获取打分记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('ptsj:score:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ptsjScoreRecordService.selectScoreRecordById(id));
    }

    /**
     * 新增打分记录
     */
    @PreAuthorize("@ss.hasPermi('ptsj:score:add')")
    @Log(title = "打分记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ScoreRecord ptsjScoreRecord)
    {
        return toAjax(ptsjScoreRecordService.insertScoreRecord(ptsjScoreRecord));
    }

    /**
     * 修改打分记录
     */
    @PreAuthorize("@ss.hasPermi('ptsj:score:edit')")
    @Log(title = "打分记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ScoreRecord ptsjScoreRecord)
    {
        return toAjax(ptsjScoreRecordService.updateScoreRecord(ptsjScoreRecord));
    }

    /**
     * 删除打分记录
     */
    @PreAuthorize("@ss.hasPermi('ptsj:score:remove')")
    @Log(title = "打分记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ptsjScoreRecordService.deleteScoreRecordByIds(ids));
    }
}
